package threadbase;

import java.util.Objects;

/**
 * lambda 表达式样例代码
 *
 *
 * @author xujian
 * Creation date 2024/3/6 22:33
 * @version 1.0
 */
public class LambdaDemo {


    public static void main(String[] args) {
        LambdaUse lambdaUse = new LambdaUse(()-> System.out.println("xxxxxx"));
        lambdaUse.execute();
    }


    static class LambdaUse{
        private LambdaFun fun;
        public LambdaUse(LambdaFun fun) {
            this.fun = fun;
        }
        public void execute(){
            if(Objects.nonNull(this.fun)){
                this.fun.doSomething();
            }
        }
    }


    @FunctionalInterface
    interface LambdaFun{
        void doSomething();
    }



}
